// NationscapeRDD
log using NationscapeRDD.log, replace

use "C:\Users\sbstjp\OneDrive - Cardiff University\Nationscapedataset.dta" // Tausanovitch, Chris and Lynn Vavreck. 2020. Democracy Fund + UCLA Nationscape, October 10-17, 2019 (version 20200814). Retrieved from [URL].  Date accessed: March 09, 2025.

*Generate date of interview variable in preparation for generation of running variable
gen dateofinterview = dofc(start_date)
format dateofinterview %td

*Delete missing values
replace statements_gender_identity=. if statements_gender_identity>4 
replace reparations=. if reparations>2 
replace group_favorability_undocumented=. if group_favorability_undocumented==999 

*Rename so consistent with Stata character limits
rename group_favorability_undocumented undocumented
rename statements_gender_identity genderidentity

*Reverse variables so social justice is coded high
foreach var in reparations undocumented {
    qui sum `var'
    local max_value = r(max)
    gen r`var' = `max_value' + 1 - `var'
}

*Keep Democrats
keep if pid3==1

* Create running variable, the date of George Floyd's murder
gen protests_start_date = td(28may2020)
gen time_to_GFprotests = dateofinterview - protests_start_date

// Regressions
rdrobust genderidentity time_to_GFprotests, c(0) p(1) kernel(triangular) bwselect(mserd)
rdrobust rreparations time_to_GFprotests, c(0) p(1) kernel(triangular) bwselect(mserd)
rdrobust rundocumented time_to_GFprotests, c(0) p(1) kernel(triangular) bwselect(mserd)

log close

